<?php
    include("html_header.html");
//include("html_footer.html");
?>
    <div id="mainContainer">
        <div class="container">
            <h1>用户列表</h1>
        </div>

        <div class="clear"></div>
        <div class="container">
            <ul>
                <li><a href='index.php'>首页</a></li>
                <li><a href='user_login.php'>注册</a></li>
            </ul>
        </div>

        <div class="clear"></div>
        <div class="container">
            <table id="mainTable" class="mainTable">
                <th>User ID</th>
                <th>Name</th>
                <th>Password</th>
                <th>Edit</th>
                <?php
                    include("user_db_connect.php");
                    //    写入和读取之前必须用这一句更改提交的中文字符编码
                    mysqli_query($link, "set names 'utf8'");
                    //获取数据
                    $sql = "select col_user_id, col_user_name, col_user_passwd
                        from tbl_user2
                        order by col_user_id
                        limit 100;";

                    $result = mysqli_query($link, $sql);

                    if ($result) {
                        while ($row = mysqli_fetch_array($result)) {
                            printf("
                <tr>
                <form action='user_edit.php' method='post'>
                    <td><input name='user_id' value='%d' type='text' readonly='readonly'/></td>
                    <td><input name='user_name' value='%s' type='text' readonly='readonly'/></td>
                    <td><input name='user_passwd' value='%s' type='text' readonly='readonly'/></td>
                    <td>
                        <button type='submit'>编辑</button>
                    </td>
                </form>
                </tr>", $row['col_user_id'], $row['col_user_name'], $row['col_user_passwd']);
                        }
                    }
                    $result = null;
                    //关闭数据库连接
                    //        mysqli_close($link);
                ?>
            </table>
        </div>

        <div class="clear"></div>
    </div>

<?php
    include("html_header.html");
//include("html_footer.html");
?>